import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

public class UpdatePassword {
    public static void main(String[] args) {
        String url = "jdbc:mysql://localhost:3306/medical_literature_system?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
        String username = "root";
        String password = "1472580369";
        
        try {
            // 加载驱动
            Class.forName("com.mysql.cj.jdbc.Driver");
            
            // 建立连接
            Connection conn = DriverManager.getConnection(url, username, password);
            
            // 更新密码
            String newPassword = "$2b$12$SxOyOJLLjbTzAMlRM8hyyuz/qfMvbjx051uMWhvEGs6e.X8TR8H46";
            String sql = "UPDATE sys_user SET password = ? WHERE username = 'admin'";
            PreparedStatement pstmt = conn.prepareStatement(sql);
            pstmt.setString(1, newPassword);
            
            int rowsAffected = pstmt.executeUpdate();
            System.out.println("Updated " + rowsAffected + " rows");
            
            // 关闭连接
            pstmt.close();
            conn.close();
            
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}